﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Kiss.Data;
using Zeus.Thunder.Core;

namespace SharpTrainer.KissData
{
    class ReadByColumn1 : ITestCase
    {
        public void Run()
        {
            Console.WriteLine("Start");

            using (DbContent db = new DbContent("NorthwindConnStr"))
            {
                try
                {
                    var query = db.DataService.ReadByColumn("Customers", "CustomerID", "ANATR");
                    DataSet ds = query.ToDataSet(db);
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        string customerId = ds.Tables[0].Rows[i]["CustomerID"].ToString();
                        string companyName = ds.Tables[0].Rows[i]["CompanyName"].ToString();
                        string contactName = ds.Tables[0].Rows[i]["contactName"].ToString();

                        Console.WriteLine("Customer ID: {0}", customerId);
                        Console.WriteLine("Company Name: {0}", companyName);
                        Console.WriteLine("Contact Name: {0}", contactName);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }

            Console.WriteLine("End");

            Console.Read();
        }
    }
}
